package com.demo2do.fms.entity.vehicle.tractor;

import org.apache.commons.lang3.StringUtils;

import com.demo2do.core.utils.Alias;

/**
 * 运输工具类型
 * 
 * @author Wy
 */
@Alias("TransMean")
public enum TransMean {
    
    /** 商品车运输车辆  */
    GOODSVEHICLES("01", "goodsVehicles", "商品车运输车辆"),
    
    /** 平板/栏板车  */
    FLAT("02", "flat", "平板/栏板/箱式/飞翼车"),
    
    /** 仓储内驳车 */
    WAREHOUSE("03", "warehouse", "仓储内驳车"),
    
    /** 救援车 */
    RESCUE("04", "rescue", "救援车");
    
    private String code;
    
    private String alias;
    
    private String description;

    /**
     * @param code
     * @param alias
     * @param description
     */
    private TransMean(String code,String alias , String description) {
        this.code = code;
        this.alias = alias;
        this.description = description;
    }
    
    /**
     * 
     * @param alias
     * @return
     */
    public static TransMean aliasOf(String alias){
        
        for(TransMean transMean : TransMean.values()){
            if(transMean.getAlias().equals(alias)){
                return transMean;
            }
        }
        
        return null;
    }
    
    /**
     * @param description
     * @return
     */
    public static TransMean descriptionOf(String description) {
        
        for (TransMean transMean : TransMean.values()) {
            if (StringUtils.equals(transMean.getDescription(), description)) {
                return transMean;
            }
        }
        
        return null;
        
    }
    
    /**
     * @return
     */
    public boolean isRescue() {
        return this.equals(RESCUE);
    }
    
    /**
     * 
     * @return code
     */
    public String getCode() {
        return code;
    }
    
    /**
     * 
     * @return  alias
     */
    public String getAlias() {
        return alias;
    }
    
    /**
     * @return the description
     */
    public String getDescription() {
        return description;
    }

}
